package com.huike.web.controller.clues;


import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.service.impl.TbClueTrackRecordServiceImpl;
import com.huike.common.annotation.Log;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 线索跟进记录Controller
 * @date 2021-04-22
 */
@RestController
@RequestMapping("/clues/record")
public class TbClueTrackRecordController extends BaseController {
    @Autowired
    TbClueTrackRecordServiceImpl tbClueTrackRecordService;

    /**
     * 新增线索跟进记录
     */
    @PreAuthorize("@ss.hasPermi('clues:record:add')")
    @Log(title = "线索跟进记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClueTrackRecordVo clueTrackRecord) {
        tbClueTrackRecordService.saveClueFollow(clueTrackRecord);
        return AjaxResult.success();
    }


    /**
     * 查询线索跟进记录列表
     */
    @PreAuthorize("@ss.hasPermi('clues:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam("clueId")Long clueId) {
       List<TbClueTrackRecord> tbClueTrackRecords = tbClueTrackRecordService.selectTbClueTrackRecords(clueId);
        TableDataInfo tableDataInfo = new TableDataInfo();
        tableDataInfo.setRows(tbClueTrackRecords);
        tableDataInfo.setTotal((long) tbClueTrackRecords.size());
        tableDataInfo.setParams(null);
        tableDataInfo.setCode(200);
        tableDataInfo.setMsg("操作成功");
        return tableDataInfo;
    }



}
